package com.yyk.dzvisit.controller.api;

import com.yyk.dzvisit.controller.BaseController;
import com.yyk.dzvisit.model.dto.req.TokenReq;
import com.yyk.dzvisit.model.dto.req.app.RecordReturnResultReq;
import com.yyk.dzvisit.model.dto.req.app.UserLoginReq;
import com.yyk.dzvisit.model.dto.resp.GetNotReturnResp;
import com.yyk.dzvisit.model.dto.resp.GetYesReturnResp;
import com.yyk.dzvisit.model.dto.resp.UserLoginInfoResp;
import com.yyk.dzvisit.service.WorkService;
import com.yyk.dzvisit.vo.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Author: ligui
 * @Date: 2020/11/24 23:32
 */
@RestController
@RequestMapping("/dz.api")
@ResponseBody
@Slf4j
@Api(value = "医生回访相关接口", tags = {"医生回访相关接口"})
//需要测试请链接-----》 http://localhost:8081/doc.html
public class WorkController extends BaseController {

    @Autowired
    private WorkService workService;


    @GetMapping("/userLogin")
    @ApiOperation(value = "登录并返回信息", notes = "登录并返回信息")
    public ApiResponse<UserLoginInfoResp> userLogin(@Validated UserLoginReq userLoginReq) {
        UserLoginInfoResp userLoginInfo = workService.getUserLoginInfo(userLoginReq);
        return successApiResponse(userLoginInfo);
    }


    @GetMapping("/getNotReturn")
    @ApiOperation(value = "未回访信息列表及详情", notes = "未回访信息列表及详情")
    public ApiResponse<List<GetNotReturnResp>> getNotReturn(@Validated TokenReq tokenReq) {
        List<GetNotReturnResp> getNotReturnResps = workService.getNotReturn(tokenReq);
        return successApiResponse(getNotReturnResps);
    }

    @GetMapping("/getYesReturn")
    @ApiOperation(value = "以回访信息列表及详情", notes = "以回访信息列表及详情")
    public ApiResponse<List<GetYesReturnResp>> getYesReturn(@Validated TokenReq tokenReq) {
        List<GetYesReturnResp> userLoginInfo = workService.getYesReturn(tokenReq);
        return successApiResponse(userLoginInfo);
    }


    @PostMapping("/recordReturnResult")
    @ApiOperation(value = "记录回访结果", notes = "记录回访结果")
    public ApiResponse recordReturnResult(@Validated RecordReturnResultReq recordReturnResultReq) {
        workService.recordReturnResult(recordReturnResultReq);
        return successApiResponse();
    }

}
